
import request from '../../utils/request'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    value: [9999, 1, 1],
    index: 0,
    date: '请选择日期',
    name:'',
    sex:'请选择性别',
    sexArr:['男','女'],
    marital:'请选择婚姻状况',
    address:'',
    experience:'请选择工作经验',
    work:'',
    position:'',
    status:'',
    salary:'',
    phone	:'',
    email:'',
    qq:'',
    assess:'',
    education:'请选择学历',
    educationArr:['硕士','本科','专科','高中'],
    maritalArr:['未婚','已婚'],
    experienceArr:['无经验','1-3年','3-5年','5-10年','10年以上'],
    region: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  bindTextAreaBlur:function(e){
    this.setData({
      assess:e.detail.value
    })
  },

  getCheck:function(e){
    var name = e.currentTarget.dataset.name 
    this.setData({
        [name]: e.detail.value
    })
  },
  getEducation:function(e){
    var index = e.detail.value
    console.log(index)
    this.setData({
      education:this.data.educationArr[index]
    })
  },
  getMarital:function(e){
    var index = e.detail.value
    this.setData({
      marital:this.data.maritalArr[index]
    })
  },
  getSex:function(e){
    var index = e.detail.value
    this.setData({
      sex:this.data.sexArr[index]
    })
  },
  getExperience:function(e){
    var index = e.detail.value
    this.setData({
      experience:this.data.experienceArr[index]
    })
  },

  getValue:function(e){
   var data = e.currentTarget.dataset.name
   console.log(data)
   this.setData({
     [data]:e.detail.value
   })
  },
  Resuame:function(){
    var data = this.data
    console.log(data)
    var params = {
      name:data.name,
      sex:data.sex,
      birthday:data.date,
      census:data.census,
      education:data.education,
      marital_status:data.marital,
      address:data.address,
      experience:data.experience,
      work_area:data.work,
      position:data.position,
      status:data.status,
      salary:data.salary,
      phone:data.phone,
      email:data.email,
      qq:data.qq,
      assess:data.assess
    }
    request.post('vitae',params).then(s=>{
      console.log(s)
      if(s.status==200){
        wx.navigateBack({
          delta: 1
        })
      }
    }).catch((err)=>{
      wx.showModal({
        content: '信息不能为空',
        showCancel:false
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})